﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SystemDirectory.Biz;
using System.Data;
using SystemDirectory.Common;

namespace SystemDirectory
{
    public partial class ProgrammeList : System.Web.UI.Page
    {
        public static bool IsCheck = false;
        public static Utilities.SearchType IsSearch = Utilities.SearchType.TypeAll;
        protected void Page_Load(object sender, EventArgs e)
        {
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }
        protected void cbxInactive_CheckedChanged(object sender, EventArgs e)
        {
            IsCheck = cbxInactive.Checked;
            BOProgramme buContact = new BOProgramme();
            DataTable dtContact = buContact.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeAll;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.Type09;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }
        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeAE;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }


        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeFJ;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }

        protected void LinkButton5_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeKM;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }

        protected void LinkButton6_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeOR;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }
        protected void LinkButton7_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeSV;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }
        protected void LinkButton8_Click(object sender, EventArgs e)
        {
            IsSearch = Utilities.SearchType.TypeWZ;
            BOProgramme boProgramme = new BOProgramme();
            DataTable dtContact = boProgramme.Get(IsCheck, IsSearch);
            PagedDataSource pds = new PagedDataSource();
            DataView dv = new DataView(dtContact);
            pds.DataSource = dv;
            pds.AllowPaging = true;
            pds.PageSize = 2;
            int NumPage = pds.PageCount;

            int CurrentPage;
            if (Request.QueryString["page"] != null)
            {
                CurrentPage = Convert.ToInt32(Request.QueryString["page"].ToString());
            }
            else
            {
                CurrentPage = 1;
            }

            pds.CurrentPageIndex = CurrentPage - 1;

            if (!pds.IsFirstPage)
            {
                hplBackward.Visible = true;
                hplBackward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage - 1);
            }
            else
            {
                hplBackward.Visible = false;
            }
            if (!pds.IsLastPage)
            {
                hplForward.Visible = true;
                hplForward.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurrentPage + 1);
            }
            else
            {
                hplForward.Visible = false;
            }


            rptContact.DataSource = pds;
            rptContact.DataBind();
            //lbnEdit.Attributes.Add("style", "margin-top: 40px;margin-right: 10px");
            lblCurrent.Text = CurrentPage.ToString();
            lblTotal.Text = NumPage.ToString();
        }
    }


}
